<?php

namespace app\common\service\SystemRabbitMqService\MessageService;
use app\common\service\SystemRabbitMqService\AmqpMessageManager;
use app\model\BbcLogModel\Sync;
use app\common\service\GoodsService\SyncGoodsService;

/**
 * 消费云仓消息中心
 * @author chenshubo
 */
class YunCangMessageService extends AmqpMessageManager
{
    const NAME = 'YC_SYNC_BBC_RECEIVE_LIST';
    protected $queueName = self::NAME,
    $routingKey = self::NAME,
    $exchangeName = self::NAME,
    $isReject = true,
    $consumer_title = "BBC MQ 消息消费";
    
    /**
     * 消费者接收消息
     */
    public function messageConsumer( $message )
    {
        //开始接受消息消费
        $MessageId   = $message['logid'];
        $cid         = (int)$message['cid'];
        $MessageType = $message['MessageType'];
        $data        = $message['data'];
        $logid       = Sync::instance()->add([
            'content'       => rawurldecode(json_encode($data,JSON_UNESCAPED_UNICODE)),
            'messageType'   => $MessageType,
            'cd'            => time(),
            'cid'           => $cid,
            'MessageId'     => $MessageId
        ]);
        $return = callApi(SyncGoodsService::class, $MessageType,$message);
        return $return;
    }
}